Skip to content

feat!: replace deterministic analysis with AI agent architecture#3

Merged
ducdmdev merged 5 commits intomainfrom
feat/ai-agent-rewrite
Feb 12, 2026
Merged

feat!: replace deterministic analysis with AI agent architecture#3
ducdmdev merged 5 commits intomainfrom
feat/ai-agent-rewrite

Conversation

@ducdmdev
Copy link
Owner

Summary

  • Replaces 3 old packages (core, cli, mcp-server) with 4 new packages (tools-core, tools, action, skill)
  • Analysis is now performed by Claude via tool calls rather than deterministic code
  • System prompt and report template live in templates/ and are embedded at build time

New Packages

Package Description
@pr-impact/tools-core Pure tool handler functions (git-diff, read-file, list-files, search-code, find-imports, list-tests)
@pr-impact/tools MCP server wrapping tools-core with zod schemas
@pr-impact/action GitHub Action with agentic Claude loop (Anthropic API, 30-iteration limit, temperature 0)
@pr-impact/skill Claude Code plugin providing /pr-impact slash command

What Changed

  • Architecture: Deterministic analysis pipeline replaced by AI agent that uses tools to gather evidence and produce reports
  • Build: Templates embedded at build time via scripts/embed-templates.ts (action) and scripts/build-skill.ts (skill)
  • Action output: CJS bundle (dist/index.cjs) with all dependencies bundled for GitHub Actions
  • Documentation: Updated root CLAUDE.md, README.md, CONTRIBUTING.md, plus README.md and CLAUDE.md for each package

Test plan

  • 54 unit tests pass across all packages (tools-core: 6 files, tools: 1 file, action: 4 files)
  • Build passes for all 4 packages
  • ESLint passes clean
  • E2E tested all 6 tools against real repo
  • E2E tested MCP server (initialize + tools/list + tools/call)
  • E2E verified action CJS bundle loads and contains all expected exports

@ducdmdev ducdmdev force-pushed the feat/ai-agent-rewrite branch 3 times, most recently from 79e3a94 to 060d89d Compare February 11, 2026 11:10
BREAKING CHANGE: Remove @pr-impact/core, @pr-impact/cli, @pr-impact/mcp-server.
Replace with 4 new packages:

- @pr-impact/tools-core: 6 pure tool handler functions (git_diff, read_file_at_ref,
  list_changed_files, search_code, find_importers, list_test_files)
- @pr-impact/tools: MCP server wrapping tools-core for Claude Code / AI assistants
- @pr-impact/action: GitHub Action with Anthropic API agentic loop (30 iterations,
  180s timeout, temperature 0, PR comment posting)
- @pr-impact/skill: Claude Code plugin with assembled skill.md from shared templates

Analysis logic moves from coded heuristics to AI reasoning via prompt templates.
Shared templates (system-prompt.md, report-template.md) define the methodology and
are embedded at build time into both the skill and action packages.

53 tests across 11 test files, all passing.
@ducdmdev ducdmdev force-pushed the feat/ai-agent-rewrite branch from 060d89d to 5cbfd52 Compare February 11, 2026 11:12
Record<string, unknown> cannot be directly asserted to specific param
types with required properties under strict mode. Cast through unknown
first.
1. Shared tool definitions (DRY):
   - Create tools-core/src/tool-defs.ts with canonical TOOL_DEFS
   - action/client.ts builds Anthropic tools from shared defs
   - tools/register.ts builds zod schemas from shared defs
   - Eliminates duplicated tool names, descriptions, and parameters

2. Client test cases (error handling, timeouts, iteration limits):
   - Tool execution error sends is_error back to Claude
   - Parallel tool_use blocks execute via Promise.all
   - Wall-clock timeout returns partial text or throws
   - Max iterations (30) returns partial text or throws

3. Risk score parsing edge cases:
   - Boundary values 0/100 and 100/100
   - Unparseable report skips threshold check
   - Score equal to threshold triggers failure (>= comparison)
   - Non-Error rejection handled in main()
Create C3v4 architecture docs covering all 4 containers, 16 components,
and 3 cross-cutting refs. Documents the system context, container
boundaries, component responsibilities, and shared patterns (git
operations, ESM conventions, build pipeline).
Doc fixes:
- Add tool-defs.ts to source layouts in CLAUDE.md and README.md
- Fix comment marker text in action/CLAUDE.md
- Add c3-generated blocks to all package CLAUDE.md files
- Update test count to 100

Code fixes:
- find-imports: strip /index suffix in normalizeModulePath so bare
  directory imports match index files
- client: throw on empty output instead of returning empty string
- comment: log warning on API failure instead of silent null return

Test additions:
- find-imports: dynamic import(), require(), directory-to-index
  resolution, unreadable file handling
- list-files: copied (C) status, binary files
@ducdmdev ducdmdev merged commit f7a298d into main Feb 12, 2026
2 checks passed
@ducdmdev ducdmdev deleted the feat/ai-agent-rewrite branch February 12, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant